package com.common;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.business.base.Pager;

public class RenderPage {

	public static String JsonByString(HttpServletResponse response,String result)
	{
		try {
			response.setContentType("text/html;charset=utf-8");
			PrintWriter pw = new PrintWriter(response.getOutputStream());
			pw.write(result);
			pw.flush();
			pw.close();
		} catch (IOException e) {

		}
		
		return "";
	}
	
	public static String JsonByObject(HttpServletResponse response,Pager<Map<String, Object>> result)
	{	
		JsonByString(response,JSON.toJSONString(result));
		
		return "";
	}
	
	public static String JsonByObject(HttpServletResponse response,List<Map<String, Object>> result)
	{	
		JsonByString(response,JSON.toJSONString(result));
		
		return "";
	}
	
	public static String JsonByObject(HttpServletResponse response,Map<String, Object> result)
	{	
		JsonByString(response,JSON.toJSONString(result));
		
		return "";
	}
}
